package com.yumeko.springcloud.controller;

import com.yumeko.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (TPayment)表控制层
 *
 * @author Zheng Hao
 * @since 2020-03-07 03:02:21
 */
@RestController
@Slf4j
public class PaymentController {
    /**
     * 服务对象
     */
    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverport;

    @RequestMapping("/payment/hystrix/ok/{id}")
    public String paymentInfoOK(@PathVariable("id") Integer id) {
        String paymentInfoOK = paymentService.paymentInfoOK(id);
        log.info("======paymentInfoOK: " + paymentInfoOK);
        return paymentInfoOK;
    }

    @RequestMapping("/payment/hystrix/timeout/{id}")
    public String paymentInfoTimeOut(@PathVariable("id") Integer id) {
        String paymentInfoTimeOut = paymentService.paymentInfoTimeOut(id);
        log.info("======paymentInfoTimeOut: " + paymentInfoTimeOut);
        return paymentInfoTimeOut;
    }

    @GetMapping("/payment/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id) {
        String paymentCircuitBreaker = paymentService.paymentCircuitBreaker(id);
        log.info("======paymentCircuitBreaker: " + paymentCircuitBreaker);
        return paymentCircuitBreaker;
    }
}